/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-08-15     Ernest Chen  the first version
 * 2023-08-15     WangShun     adapt to YOC
 */

#ifndef __AHT10_H__
#define __AHT10_H__

#include <stdio.h>
#include <devices/iic.h>
#include <devices/devicelist.h>
#include <aos/aos.h>
#include "aos/cli.h"

struct aht10_device
{
    rvm_dev_t *i2c;
    aos_mutex_t lock;
};
typedef struct aht10_device *aht10_device_t;

/**
 * This function initializes aht10 registered device driver
 *
 * @param dev the name of aht10 device
 *
 * @return the aht10 device.
 */
aht10_device_t aht10_init(const char *i2c_bus_name, unsigned int iic_idx);

/**
 * This function releases memory and deletes mutex lock
 *
 * @param dev the pointer of device driver structure
 */
int aht10_deinit(aht10_device_t dev);

/**
 * This function reads temperature by aht10 sensor measurement
 *
 * @param dev the pointer of device driver structure
 *
 * @return the relative temperature converted to float data.
 */
float aht10_read_temperature(aht10_device_t dev);

/**
 * This function reads relative humidity by aht10 sensor measurement
 *
 * @param dev the pointer of device driver structure
 *
 * @return the relative humidity converted to float data.
 */
float aht10_read_humidity(aht10_device_t dev);

#endif /* __DRV_AHT10_H__ */
